package main

import (
	"blog/controllers"
	"blog/models"
	_ "blog/routers"
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/plugins/cors"
)

func init() {
	models.Init()
}

func main() {
	if beego.AppConfig.String("runmode") == "dev" {
		//orm.Debug = true
		beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
			//允许访问所有源
			AllowAllOrigins: true,
		}))
	}
	//orm.Debug = true
	// 自动建表
	//orm.RunSyncdb("default", false, true)
	beego.ErrorController(&controllers.ErrorController{})

	beego.Run()

}
